<%@ page language="java" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!doctype html>
<html lang="en">

<head>
<title>Home</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<!-- VENDOR CSS -->
<link rel="stylesheet"
	href="assets/vendor/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet"
	href="assets/vendor/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="assets/vendor/linearicons/style.css">
<link rel="stylesheet"
	href="assets/vendor/chartist/css/chartist-custom.css">
<!-- MAIN CSS -->
<link rel="stylesheet" href="assets/css/main.css">
<!-- FOR DEMO PURPOSES ONLY. You should remove this in your project -->
<link rel="stylesheet" href="assets/css/demo.css">
<!-- GOOGLE FONTS -->
<link
	href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700"
	rel="stylesheet">
<!-- ICONS -->
<link rel="apple-touch-icon" sizes="76x76"
	href="assets/img/apple-icon.png">
<link rel="icon" type="image/png" sizes="96x96"
	href="assets/img/favicon.png">
</head>

<body>

	<jsp:include page="/assets/jsp/header.jsp" flush="true" />
	<jsp:include page="/assets/jsp/menu.jsp" flush="true" />
	<!-- MAIN -->
	<div class="main">
		<!-- MAIN CONTENT -->
		<form class="form-horizontal" role="form" action="##" id="form4"
			method="post">
			<fieldset>
				<legend></legend>
				
				<div class="form-group">
					<label class="col-sm-2 control-label" for="customer_id_type">证件类型</label>
					<div class="col-sm-4">
						<select id="customer_id_type" name="customer_id_type"
							class="form-control">
							<option value="01">01-身份证</option>
							<option value="02">02-护照</option>
							<option value="03">03-驾照</option>
							<option value="04">04-其他</option>
						</select>
					</div>
					<label class="col-sm-2 control-label" for="customer_idno">证件号</label>
					<div class="col-sm-4">
						<input class="form-control" id="customer_idno"
							name="customer_idno" type="text" placeholder="请输入证件号"  onchange="queryCustomer();"/>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label" for="customer_number">客户号</label>
					<div class="col-sm-4">
						<input class="form-control" id="customer_number"
							name="customer_number"  type="text"
							placeholder="请输入客户号" />
					</div>

					<label class="col-sm-2 control-label" for="customer_name">客户名称</label>
					<div class="col-sm-4">
						<input class="form-control" id="customer_name"
							name="customer_name" type="text" placeholder="请输入客户名称" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label" for="customer_phone">手机号</label>
					<div class="col-sm-4">
						<input class="form-control" id="customer_phone"
							name="customer_phone" type="text" placeholder="请输入手机号" />
					</div>
					<label class="col-sm-2 control-label" for="customer_email">邮箱</label>
					<div class="col-sm-4">
						<input class="form-control" id="customer_email"
							name="customer_email" type="text" placeholder="请输入客户邮箱" />
					</div>
				</div>
				
				<div class="form-group">
					<label class="col-sm-2 control-label" for="currency">货币代号</label>
					<div class="col-sm-4">
						<select id="currency" name="currency" class="form-control">
							<option value="01">01-人民币</option>
							<option value="02">02-美元</option>
							<option value="03">03-日元</option>
							<option value="04">04-英镑</option>
						</select>
					</div>
					<label class="col-sm-2 control-label" for="senior_oir">营业机构号</label>
					<div class="col-sm-4">
						<input class="form-control" id="senior_oir" name="senior_oir"
							type="text" readonly="readonly"
							value="<%out.print(session.getAttribute("session_user_ori"));%>" />
					</div>

				
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label" for="accounting_ori">帐务机构</label>
					<div class="col-sm-4">
						<input class="form-control" id="accounting_ori"
							name="accounting_ori" type="text" readonly="readonly"
							value="<%out.print(session.getAttribute("session_user_ori"));%>" />
					</div>

				
					<label class="col-sm-2 control-label" for="attribute">客户类型:</label>
					<div class="col-sm-4">
						<select id="attribute" name="attribute" class="form-control">
							<option value="01">01-对公</option>
							<option value="02">02-对私</option>
						</select>
					</div>
				
				</div>
				<div  class="form-group">
					<label class="col-sm-2 control-label" for="acct_type" >账户类型:</label>
					<div class="col-sm-4">
						<select id="acct_type" name="acct_type" class="form-control" onchange="queryRate();">
							<option value="01">01-活期</option>
							<option value="02">02-定期</option>
						</select>
					</div>
					<label class="col-sm-2 control-label" for="deposit_time">存期</label>
					<div class="col-sm-4">
						<select id="deposit_time" name="deposit_time" class="form-control" onchange="queryRate();">
							<option value="01">01-1个月</option>
							<option value="02">02-2个月</option>
							<option value="03">03-3个月</option>
							<option value="04">03-1年</option>
							<option value="05">03-3年</option>
							<option value="06">03-5年</option>
						</select>
					</div>
				</div>
				<div class="form-group">
				
					<label class="col-sm-2 control-label" for="rate_value">利率</label>
					<div class="col-sm-4">
						<input class="form-control" id="rate_value"
						name="rate_value" type="text" readonly="readonly"/>
					</div>
						<label class="col-sm-2 control-label" for="password">交易密码</label>
					<div class="col-sm-4">
						<input class="form-control" id="password"
						name="password" type="password" />
					</div>
				</div>
				
			
			</fieldset>
			<fieldset>
				<legend></legend>
				<div class="form-group">
					<label class="col-sm-2 control-label" for="submit"></label>
					<div class="col-sm-4">
						<input type="button" class="btn btn-default" onclick="openAccountConfirm();"
							value="提交" />
					</div>
				</div>
			</fieldset>
		</form>
		<!-- END MAIN CONTENT -->

		<!-- END MAIN CONTENT -->
	</div>
	<!-- END MAIN -->
	<div class="clearfix">
		<footer>
			<div class="container-fluid">
				<p class="copyright">Copyright &copy; 2018.Company Shanbrain-bankli
					All rights reserved.More Templates</p>

			</div>
		</footer>
	</div>
	</div>
	<!-- END WRAPPER -->
	<!-- Javascript -->
	<script src="assets/vendor/jquery/jquery.min.js"></script>
	<script src="assets/vendor/bootstrap/js/bootstrap.min.js"></script>
	<script src="assets/vendor/jquery-slimscroll/jquery.slimscroll.min.js"></script>
	<script
		src="assets/vendor/jquery.easy-pie-chart/jquery.easypiechart.min.js"></script>
	<script src="assets/vendor/chartist/js/chartist.min.js"></script>
	<script src="assets/scripts/klorofil-common.js"></script>
		<script src="assets/scripts/common.js"></script>	
	<script type="text/javascript">
		$("#subPages3").addClass("in");
		function queryCustomer() {
			var data = new Object();
			data.customer_id_type = $("#attribute").val();
			data.customer_idno = $("#customer_idno").val();
			$.ajax({
				type : "POST",
				dataType : "json",
				contentType : "application/json",
				url : "/brain-bank/doQueryCustomer.do",
				data : JSON.stringify(data),
				success : function(result) {
					if (result.returncode == "success") {
						fillField(result);
					}
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {
					alert("执行失败");
					alert(XMLHttpRequest.status);
					alert(XMLHttpRequest.readyState);
					alert(textStatus);
				}
			});
		}

		function fillField(param) {
			$("#customer").attr("readonly", true);
			$("#customer_name").val(param.customer_name);
			$("#customer_name").attr("disabled", false);
			$("#customer_idno").val(param.customer_idno);
			$("#customer_idno").attr("disabled", false);
			$("#customer_id_type").val(param.customer_id_type);
			$("#customer_id_type").attr("disabled", false);
			$("#customer_number").val(param.customer_number);
			$("#customer_phone").val(param.customer_phone);
			$("#customer_email").val(param.customer_email);
			$("#customer_address").val(param.customer_address);
		}
		function openAccountConfirm(){
			$.MsgBox.Confirm("温馨提示","开户确认", doOpenAccount);
		 }
		function doOpenAccount(){
			var data = new Object();
			data.customer_name = $("#customer_name").val();
			data.customer_idno = $("#customer_idno").val();
			data.customer_id_type = $("#customer_id_type").val();
			data.customer_number = $("#customer_number").val();
			data.customer_idno = $("#customer_idno").val();
			data.customer_phone = $("#customer_phone").val();
			data.customer_email = $("#customer_email").val();
			data.currency = $("#currency").val();
			data.senior_oir = $("#senior_oir").val();
			data.attribute = $("#attribute").val();
			data.acct_type = $("#acct_type").val();
			data.deposit_time = $("#deposit_time").val();
			data.rate_value = $("#rate_value").val();
			data.password = $("#password").val();
			data.accounting_ori = $("#accounting_ori").val();
			
			$.ajax({
				type: "POST",//方法类型
                dataType: "json",//预期服务器返回的数据类型
                contentType : "application/json",
                url: "/brain-bank/doOpenAccount.do" ,//url
                data: JSON.stringify(data),
		 		success:function(result){
		 			if (result.returncode == "success") {
		 				$.MsgBox.Alert("温馨提示", "客户增加成功", function(){window.location.href="/brain-bank/addClient.do";});
					}
					if (result.returncode == "failed"){
	           		 	$.MsgBox.Alert("温馨提示", result.msg, function(){});
					}
           		 	
		 		},
		 		error: function(XMLHttpRequest, textStatus, errorThrown){
	            	alert("执行失败");
	                alert(XMLHttpRequest.status);
	                alert(XMLHttpRequest.readyState);
	                alert(textStatus);
	             }
		 	});
		}
		function queryRate(){
			var data = new Object();
			data.attribute = $("#attribute").val(); //对公对私
			data.acct_type = $("#acct_type").val(); //活期定期
			data.rateId = data.attribute+data.acct_type;
			$.ajax({
				type : "POST",
				dataType : "json",
				contentType : "application/json",
				url : "/brain-bank/getRateInfo.do",
				data : JSON.stringify(data),
				success : function(result) {
					if (result.returncode == "success") {
						$("#rate_value").val(result.rate);
					}
					if (result.returncode == "failed"){
	           		 	$.MsgBox.Alert("温馨提示", result.msg, function(){});
					}
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {
					alert("执行失败");
					alert(XMLHttpRequest.status);
					alert(XMLHttpRequest.readyState);
					alert(textStatus);
				}
			});
		}
		
		
		
		
		
		
	</script>
	
	
	
	
	

</body>

</html>
